home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’92 / NotificationMon ƒ / NotificationMon.ƒ / Source / ScrollBar.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-22  |  846 b   |  49 lines  |  [TEXT/KAHL]

  1. #include "ScrollBar.h"
  2.  
  3. void CalcScrollBounds(WindowPtr wp, Rect *cBounds)
  4. {
  5.     *cBounds = wp->portRect;
  6.     cBounds->top -= 1;
  7.     cBounds->right += 1;
  8.     cBounds->left = cBounds->right - 16;
  9.     cBounds->bottom -= 14;
  10. }
  11.  
  12. ControlHandle NewVScrollBar(WindowPtr wp)
  13. {
  14.     GrafPtr            savePort;
  15.     ControlHandle    cHandle;
  16.     Rect            cBounds;
  17.     
  18.     GetPort(&savePort);
  19.     SetPort(wp);
  20.     
  21.     CalcScrollBounds(wp, &cBounds);
  22.     
  23.     cHandle = NewControl( wp, &cBounds, "\pVGrooviScroller", 
  24.                             true, 1, 1, 1,
  25.                          scrollBarProc, (long)wp);
  26.         
  27.     
  28.     SetPort(savePort);
  29.     
  30.     return cHandle;
  31. }
  32.  
  33. void SizeVScrollBar(ControlHandle scroll, WindowPtr wp)
  34. {
  35.     GrafPtr            savePort;
  36.     ControlHandle    cHandle;
  37.     Rect            cBounds;
  38.     
  39.     GetPort(&savePort);
  40.     SetPort(wp);
  41.     
  42.     CalcScrollBounds(wp, &cBounds);
  43.     
  44.     HideControl(scroll);
  45.     (**scroll).contrlRect = cBounds;
  46.     ShowControl(scroll);
  47.     
  48.     SetPort(savePort);
  49. }